home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / What's New? / Development Kits / Apple Game Sprockets DR1 / Examples / SoundSprocketTest / TS3Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-24  |  3.3 KB  |  165 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    File:        TS3Main.c
  3.  *    Author:        Dan Venolia
  4.  *
  5.  *    Contents:    Main entry point, main loop, initialize and exit code
  6.  *
  7.  *    Copyright © 1996 Apple Computer, Inc.
  8.  */
  9.  
  10. #include <Dialogs.h>
  11. #include <Fonts.h>
  12. #include <Memory.h>
  13. #include <QuickDraw.h>
  14. #include <Types.h>
  15. #include <Windows.h>
  16.  
  17. #include <QD3D.h>
  18.  
  19. #include "TS3Events.h"
  20. #include "TS3Main.h"
  21. #include "TS3Menu.h"
  22. #include "TS3Message.h"
  23. #include "TS3Sound.h"
  24. #include "TS3TestAPI.h"
  25. #include "TS3TestHiLevel.h"
  26. #include "TS3TestLoLevel.h"
  27. #include "TS3Utils.h"
  28. #include "TS3Window.h"
  29.  
  30. #ifdef APP_LOADS_SOUND_COMPONENT
  31.     #include "S3Private.h"
  32. #endif
  33.  
  34. void main(
  35.     void);
  36.  
  37. static void Init(
  38.     void);
  39.  
  40. static void Exit(
  41.     void);
  42.  
  43.  
  44. static Boolean gAlive = false;
  45.  
  46.  
  47.  
  48. /* =============================================================================
  49.  *        main
  50.  *
  51.  *    Initializes, processes events, does the idle-time stuff, and exits.
  52.  * ========================================================================== */
  53. void main(
  54.     void)
  55. {
  56.     Init();
  57.     
  58.     while (gAlive)
  59.     {
  60.         Events_Process();
  61.     }
  62.     
  63.     Exit();
  64. }
  65.  
  66.  
  67. /* =============================================================================
  68.  *        Main_LastRoundup (external)
  69.  *
  70.  *    Requests the main event loop to gracefully exit.
  71.  * ========================================================================== */
  72. void Main_LastRoundup(
  73.     void)
  74. {
  75.     gAlive = false;
  76. }
  77.  
  78.  
  79. /* =============================================================================
  80.  *        Init (internal)
  81.  *
  82.  *    Initialization of toolbox and our stuff.
  83.  * ========================================================================== */
  84. void Init(
  85.     void)
  86. {
  87.     // Initialize the toolbox
  88.      MaxApplZone();
  89.     MoreMasters();
  90.     
  91.     InitGraf(&qd.thePort);
  92.     InitFonts();
  93.     InitWindows();
  94.     InitDialogs(NULL);
  95.     InitCursor();
  96.     InitMenus();
  97.     TEInit();
  98.     
  99.     // Should we load S3Localization?
  100.     #ifdef APP_LOADS_SOUND_COMPONENT
  101.     {
  102.         ComponentDescription    filterDesc;
  103.         Handle                    filterNameHdl;
  104.         Handle                    infoHdl;
  105.         
  106.         // Register (or find) our components
  107. #ifdef REAL_3D_INSTALL
  108.         filterDesc.componentType            = kSoundEffectsType;
  109. #else
  110.         filterDesc.componentType            = 'sdec';
  111. #endif
  112.         filterDesc.componentSubType            = 'snd3';
  113.         filterDesc.componentManufacturer    = 'appl';
  114.         filterDesc.componentFlags            = 0L;
  115.         filterDesc.componentFlagsMask        = 0L;
  116.         
  117.         filterNameHdl = NewHandle (sizeof (Str255));
  118.         BlockMove ((Ptr)"\pS3Localization", (Ptr)(*filterNameHdl), sizeof (Str255));
  119.  
  120.         infoHdl = NewHandle (sizeof (Str255));
  121.         BlockMove ((Ptr)"\pThis component provides 3D Audio.", (Ptr)(*infoHdl), sizeof (Str255));
  122.         
  123.         // Register the Filter component
  124.         RegisterComponent (&filterDesc, NewComponentRoutineProc(SoundComponentProc), kRegisterGlobally,
  125.             filterNameHdl, infoHdl, nil);
  126.     }
  127.     #endif
  128.     
  129.     // Initialize our modules
  130.     Utils_Init();
  131.     Message_Init();
  132.     Menu_Init();
  133.     Events_Init();
  134.     Window_Init();
  135.     Sound_Init();
  136.     TestAPI_Init();
  137.     TestHiLevel_Init();
  138.     TestLoLevel_Init();
  139.     
  140.     // We're off...
  141.     gAlive = true;
  142. }
  143.  
  144.  
  145. /* =============================================================================
  146.  *        Exit (internal)
  147.  *
  148.  *    Cleans up before exit.
  149.  * ========================================================================== */
  150. void Exit(
  151.     void)
  152. {
  153.     // Exit our modules
  154.     TestLoLevel_Exit();
  155.     TestHiLevel_Exit();
  156.     TestAPI_Exit();
  157.     Sound_Exit();
  158.     Window_Exit();
  159.     Events_Exit();
  160.     Menu_Exit();
  161.     Message_Exit();
  162.     Utils_Exit();
  163. }
  164.  
  165.